 <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript">
 $(document).ready(function(){
		$(":input[name=managerAll]").click(function(){
			$.ajax({
				url:"${initParam.root}member/getAllManager.moja",
		        data:$("#managerForm").serialize(),
		        dataType:"json", 
		        success:function(jsonData){
		        	var tl="<table border=1><tr><td><b>ID</b></td><td><b>Name</b></td><td><b>Password</b></td><td><b>Nickname</b></td><td><b>Gender</b></td><td><b>Birthday</b></td><td><b>Email</b></td><td><b>Point</b></td><td><b>Phone</b></td><td><b>grade</b></td></tr>";
		        	$.each(jsonData,function(index,manager){
		        		//alert(manager.memberId);
		        		tl+="<tr><td>"+manager.memberId+"</td><td>"+manager.memberName+"</td><td>"+manager.memberPassword+"</td><td  align=center>"+manager.memberNickname+
		        		"</td><td>"+manager.memberGender+"</td><td>"+manager.memberBirthday+"</td><td>"+manager.memberEmail+"</td><td>"+
		        		manager.memberPoint+"</td><td>"+manager.memberPhone+"</td><td>"+manager.grade+"</td></tr>";
		        	});
					tl+="</table>";
					$("#managerView").html(tl);
		      }
		});
	});
		$(":input[name=deleteMember]").click(function(){
			$("#memberTbl td").click(function(){
			var memberId=$(this).parent().children().eq(0).text();
			//if(confirm("강퇴하시겠습니까?")){
				$.ajax({
					url:"${initParam.root }member/auth_manager_ajaxdeleteMember.moja",
			        data:"memberId="+memberId,
			        dataType:"json", 
			        success:function(jsonData){
			        	location.href="${initParam.root }member/auth_manager_memberList.moja";
			        }
				});//ajax 
		//	}
		});
	}); // click
	
	
	$(":input[name=passBtn]").click(function(){
		var memberId=$(this).parent().parent().children().eq(0).text();
		var thisTable = $(this).parent();
		alert(memberId);
		alert(thisTable);
		if(confirm("판매권한을 주겠습니까?")){
			$.ajax({
				url:"${initParam.root }member/auth_manager_passAuthorityMember.moja",
		        data:"memberId="+memberId,
		        //dataType:"json", 
		        success:function(jsonData){
		        	thisTable.html("판매가능회원");
		        }
			});//ajax 
		}
		
	})
 });
 </script> 
  <style>
 .gray {
    color: #e9e9e9;
/*     border: solid 1px #555;
 */    background: #6e6e6e;
    background: -webkit-gradient(linear, left top, left bottom, from(#888), to(#575757));
    background: -moz-linear-gradient(top,  #888,  #575757);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#888888', endColorstr='#575757');
 }
 </style> 
 <div id="mainCss" align="center">
 <form id="managerForm"<%--  action="${initParam.root}member/auth_manager_deleteMember.moja" --%>>
    <div id="allMemberView">
    <table border="1" id="memberTbl">
    <tr>
	<td colspan="13" bgcolor="black" align="center"><br><font color="#FFFFFF" size="4">전 체 회 원 명 단</font><br><br></td>
	</tr>
    <tr align="center">
    	<td><b>ID</b></td>
    	<td width="30"><b>Name</b></td>
    	<td><b>Password</b></td>
    	<td><b>Nickname</b></td>
    	<td><b>Gender</b></td>
    	<td><b>Birthday</b></td>
    	<td><b>Email</b></td>
    	<td><b>Point</b></td>
    	<td><b>Phone</b></td>
    	<td>grade</td>
    	<td><b>강퇴<br>여부</b></td>
    	<td width="50"><b>판매<br>권한</b></td>
    </tr>
    <c:forEach items="${requestScope.mlist}" var="str">
    	<c:choose>
    		<c:when test="${str.memberPoint!=-1}">
    	<tr align="center">
    		<td><a href="${initParam.root}member/auth_manager_showMemberContent.moja?memberId=${str.memberId}"/>${str.memberId}</td>
	    	<td width="30">${str.memberName}</td>
	    	<td>${str.memberPassword}</td>
	    	<td>${str.memberNickname}</td>
	    	<td>${str.memberGender}</td>
	    	<td>${str.memberBirthday}</td>
	    	<td>${str.memberEmail}</td>
	    	<td>${str.memberPoint}</td>
	    	<td>${str.memberPhone}</td>
	    	<td>${str.grade }</td>
	    	<td><input type="button" name=deleteMember value="강퇴"><input type="hidden" id="memberId" name="memberId" value="${str.memberId}"></td>
	    	<td width="50">
	    		<c:choose>
	    			<c:when test="${str.memberSellAuthority == 'middle' }">
	    				<input type = "button" name = "passBtn" value = "판매권한 승인">
	    			</c:when>
	    			<c:when test="${str.memberSellAuthority == 'fail' }">
	    				일반회원
	    			</c:when>
	    			<c:otherwise>
	    				판매가능회원
	    			</c:otherwise>
	    		</c:choose>
	    	</td>
    	</tr>
    	</c:when>
    	</c:choose>
    </c:forEach>
    </table>
    </div>
    </form> <br><br>
        <input type="button" name="managerAll" value="관리자명단보기" class="gray"><br><br>
	<div id="managerView"></div>
	</div>